#ifndef LAYERMODEL_HPP
#define LAYERMODEL_HPP
#include "collidable_obj.hpp"
#include "ground.hpp"
#include <cassert>
using namespace std;

using ObjectList = vector<Object*>;

struct Map{
    Map() = default;
    Map(int w, int h);
    void Resize(int w, int h);
    int GetWidth() const;
    int GetHeight() const;
    vector<vector<Object*>> map_;
};

/* @brief 存储一个层的类，存储一个层的信息 */
class LayerModel{
public:
    LayerModel(int width, int height);
    void AddObject(Object* object);
    /* @brief 将物体从layer中移除(不释放内存) */
    void RemoveObject(Object* object);
    /* @brief 获得(x, y)处非生物物体 */
    Object* GetObjAt(int x, int y);
    Object* GetCreatureAt(int x, int y);
    const Map& GetMap() const;
    /* @brief 地图的左上角绘制坐标*/
    void Draw(int x, int y);
    void Update();
private:
    Map _map;  /** 地图 */
    int _width;
    int _height;
    ObjectList _objects;
    ObjectList _creatures;
};

#endif

